<%@page import="data.Promotion"%>
<%@page import="messages.SystemMessage"%>
<%@page import="data.Succursale"%>
<%@page import="java.util.ArrayList"%>
<%@page import="controlleur.succursaleControlleur"%>
<%
	String titre = "Ajouter Promotion";
	Promotion promotion= new Promotion();
	//recuperer la succursale
	if(!request.getParameter(SystemMessage.PROMOTION_ID).isEmpty())
	{
		if(request.getParameter(SystemMessage.PROMOTION_ID).equals("-1"))
		{				
			promotion.setId(-1);
			//...
			
		}
	}
	
%>
<jsp:include page="../part/header.jsp" />	

<script>

$(function() {

	$("#callAjax").click(function() {
	var vnom = $.trim($("#nom").val());
	
	
		if(validate()){			
			$.ajax({
			type: "GET",
			url: "<%= request.getContextPath() %>/ajax/savePromotionAjax.jsp",
			data: ({nom: vnom}),
			cache: false,
			dataType: "text",
			success: onSuccess
			});			
		}
	});
	
		$("#resultLog").ajaxError(function(event, request, settings, exception) {
		$("#resultLog").html("Error Calling: " + settings.url + "<br />HTPP Code: " + request.status);
	});

	function onSuccess(data)
	{
		$("#resultLog").html("Result: " + data);
		//$.mobile.changePage( "listeSuccursales.jsp", { transition: "flip"} );
		window.location.href = "listSuccursales.jsp";
	}
	function validate()
	{
		return true;
	}
});



</script>



 <form id="editSucc">
	<div data-role="header" data-position="inline">
		<a href="javascript: history.go(-1)" data-icon="delete">Annuler</a>
		<h1><%=titre %></h1>			
		<a onclick="$('form#editProm').trigger('submit')" data-role="button" data-icon="check" id="callAjax">Sauvegarder</a>
	</div>
	
	
	 <div data-role="content">
           
         <div data-role="fieldcontain">
               <label for="nom">Nom</label>
               <input type="text" name="nom" id="nom" value="" />

               <label for="desc">Description</label>
               <input type="text" name="desc" id="desc" value="" />
               
              <label for="dateDebut">Debut</label>
			  <input type="text" name="dateDebut" id="dateDebut" value=""  />
			  
			  <label for="dateFin">Fin</label>
			  <input type="text" name="dateFin" id="dateFin" value=""  />
               
               <B>Select a fruit:</B> <BR>
				<SELECT NAME="Fruit">
				<OPTION> Apples
				<OPTION> Bananas
				<OPTION> Oranges
				</SELECT>
                               
           </div>
            
     </div>
     <input type="hidden" name="idDetaillant" id="idDetaillant" value="<%=session.getAttribute(SystemMessage.DETAILLANT_ID) %>" />
     <input type="hidden" name="idSuccursale" id="idSuccursale" value="<%=request.getParameter(SystemMessage.SUCCURSALE_ID) %>" />
</form>

<div id="resultLog">Rien</div> 



<jsp:include page="../part/footer.jsp" />	